package de.mmis.core.base.abstracttree.serializer.internal;

import java.lang.reflect.Array;
import java.util.Map;

import de.mmis.core.base.abstracttree.InnerNode;
import de.mmis.core.base.abstracttree.Tree;
import de.mmis.core.base.abstracttree.serializer.Serializer;

/**
 * Meta-Serializer class for serializing arrays of objects to Trees
 * 
 * @author Christian Koch
 */
class ArraySerializer implements Serializer<Object> {
	@Override
	public Tree serialize(Object object, boolean explicit,
			Map<Object, String> refmap, ClassLoader classLoader) {

		InnerNode ret = new InnerNode();
		for (int i = 0; i < Array.getLength(object); i++)
			ret.add(Tree.fromObject(Array.get(object, i), explicit, refmap,
					classLoader));
		return ret;
	}
}
